<?php

namespace app\api\controller;

use app\common\controller\Api;

/**
 * 新闻模块
 */

class News extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 新闻列表
     * @ApiTitle    (新闻列表)
     * @ApiMethod   (GET)
     * @ApiRoute    (/api/news/getPageList/mold/{mold}/is_index_show/{is_index_show}/page/{page}/limit/{limit})
     * @ApiParams   (name="mold", type="string", required=true, description="分类:company=公司新闻,industry=行业新闻")
     * @ApiParams   (name="is_index_show", type="string", required=true, description="首页展示:0=否,1=是")
     * @ApiParams   (name="page", type="string", required=true, description="页码")
     * @ApiParams   (name="limit", type="string", required=true, description="条数")
     */
    public function getPageList(\app\common\model\NewsModel $NewsModel)
    {
        $mold = $this->request->request('mold');
        $is_index_show = $this->request->request('is_index_show',0);
        $page = $this->request->request('page',1);
        $limit = $this->request->request('limit',5);
        if(!$mold) {
            $this->error('参数错误', [], 40001);
        }
        $data = $NewsModel->getPageList($is_index_show,$mold,$page,$limit);
        $this->error($data['msg'], $data['data'], $data['code']);
    }

    /**
     * 新闻详情
     * @ApiTitle    (新闻详情)
     * @ApiMethod   (GET)
     * @ApiRoute    (/api/news/getDetail/id/{id})
     * @ApiParams   (name="id", type="integer", required=true, description="新闻ID")
     */
    public function getDetail(\app\common\model\NewsModel $NewsModel)
    {
        $id = $this->request->request('id');
        if(!$id) {
            $this->error('参数错误', [], 40001);
        }
        $data = $NewsModel->getDetail($id);
        $this->error($data['msg'], $data['data'], $data['code']);
    }

}